package com.ruix.app.ui.adapter;

import android.content.Context;
import android.view.View;

import com.ruix.app.R;
import com.ruix.app.adapter.superadapter.IMulItemViewType;
import com.ruix.app.adapter.superadapter.SuperAdapter;
import com.ruix.app.adapter.superadapter.internal.SuperViewHolder;
import com.ruix.app.model.Classes;
import com.ruix.app.model.PostsCard;

import java.util.List;

/**
 * Created by hadexs on 2017/4/14.
 */

public class ClassListAdapter extends SuperAdapter<Classes> {

    public ClassListAdapter(Context context) {
        super(context, R.layout.item_grade_list);//
    }

    public ClassListAdapter(Context context, List<Classes> items, IMulItemViewType<Classes> mulItemViewType) {
        super(context, items, mulItemViewType);
    }


    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, Classes item) {
        if (item != null){
            holder.setSimpleDraweeURI(R.id.iv_grade_icon,item.getIcon());
            holder.setText(R.id.tv_class_name_title, item.getName());
            if (viewType ==0){  //班级圈子
                holder.setText(R.id.tv_class_desc, item.getLastPost());
                if (item.isHaseNewMessage()) {
                    holder.setVisibility(R.id.iv_new_tag, View.VISIBLE);
                } else {
                    holder.setVisibility(R.id.iv_new_tag, View.INVISIBLE);
                }
                if (item.isClassType()){
                    holder.setVisibility(R.id.tag_class_view, View.VISIBLE);
                } else {
                    holder.setVisibility(R.id.tag_class_view, View.GONE);
                }

                if ("3".equals(item.getStatus())){
                    holder.setVisibility(R.id.iv_state_finish, View.VISIBLE);
                } else {
                    holder.setVisibility(R.id.iv_state_finish, View.GONE);
                }
            } else if (viewType ==1){//组织圈
                String desc = String.format("%s个圈子 %s个成员",item.getClassNum(),item.getMemberNum());
                holder.setText(R.id.tv_class_desc, desc);
                if (item.hasNews()) {
                    holder.setVisibility(R.id.iv_new_tag, View.VISIBLE);
                } else {
                    holder.setVisibility(R.id.iv_new_tag, View.INVISIBLE);
                }
                holder.setVisibility(R.id.iv_state_finish, View.VISIBLE);
            }


//            holder.setBackgroundResource(R.id.iv_class_icon, R.drawable.circle_recommend_bg);
//            if (item.getID().equals("recommend")) {
//                holder.setImageViewSrc(R.id.iv_class_icon, R.drawable.circle_recommend_src);
//            } else {
//                holder.setImageViewSrc(R.id.iv_class_icon, R.drawable.circle_sugest_src);
//            }
        }
    }
}
